<!DOCTYPE html><html lang="en"><head><link rel="stylesheet" href="./style.css"><title>Uncategorized - 30 seconds of code</title><meta charset="utf-8"><meta name="description" content="Curated collection of useful Javascript snippets that you can understand in 30 seconds or less."><meta name="keywords" content="javascript, snippets, code, programming"><meta name="author" content="Angelos Chalaris (chalarangelo@gmail.com)"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="theme-color" content="#111"><meta property="og:title" content="30 seconds of code"><meta property="og:description" content="Curated collection of useful Javascript snippets that you can understand in 30 seconds or less."/><meta property="og:type" content="website"/><meta property="og:image" content="https://30secondsofcode.org/logos/logo_512.png"><link rel="icon" type="image/png" href="./logos/logo_128.png"><link rel="manifest" href="manifest.json"><script>const search = (node) => {
        let matchingTags = [];
        Array.from(node.parentElement.getElementsByTagName('a')).forEach(x => {
          let data = [x.textContent.toLowerCase(), ...x.getAttribute('tags').split(',')].map(v => !!(v.indexOf(node.value.toLowerCase()) + 1));
          if(data.includes(true)){
            x.style.display = '';
            matchingTags.push(x.getAttribute('tags').split(',')[0]);
          }
          else x.style.display = 'none';
        });
        Array.from(node.parentElement.getElementsByTagName('h4')).forEach(x => {
          x.style.display = matchingTags.includes(x.textContent.toLowerCase()) ? '' : 'none';
        })
      }
      function scrollToTop(){
        const c = document.querySelector('.card-container').scrollTop;
        if (c > 0) {
          window.requestAnimationFrame(scrollToTop);
          document.querySelector('.card-container').scrollTo(0, c - c / 4);
        }
      };
      function scrollTo(element, to, id, duration) {
        if (duration <= 0) return;
        var difference = to - element.scrollTop;
        var perTick = difference / duration * 40;

        setTimeout(function() {
            element.scrollTop = element.scrollTop + perTick;
            if (element.scrollTop === to) {
              window.location.href = "#"+id;
              return;
            }
            scrollTo(element, to, id, duration - 40);
        }, 40);
      };
      function loader() {
        registerClickListener();
        if(window.innerWidth >= '768')
          document.querySelector('nav').scrollTop = Array.from(document.querySelectorAll('h4')).filter(v => v.innerHTML === 'Uncategorized')[0].offsetTop;
        else
          document.querySelector('nav').scrollTop = Array.from(document.querySelectorAll('h4')).filter(v => v.innerHTML === 'Uncategorized')[0].offsetTop;
      }
      function registerClickListener() {
        document.addEventListener('click', function (event) {
          if ( event.target.classList.contains('collapse') ) {
            event.target.classList = event.target.classList.contains('toggled') ? 'collapse' : 'collapse toggled';
          }
          else if (event.target.classList.contains('menu-button')) {
            document.querySelector('nav').classList = event.target.classList.contains('toggled') ? '' : 'col-nav';
            event.target.classList = event.target.classList.contains('toggled') ? 'menu-button' : 'menu-button toggled';
          }
          else if (!document.querySelector('nav').contains(event.target) && window.innerWidth < '768') {
            document.querySelector('nav').classList = '';
            document.querySelector('.menu-button').classList = 'menu-button';
          }
          else if (event.target.classList.contains('copy-button')) {
            const text = event.target.parentElement.parentElement.querySelector(':not(pre) + pre').textContent;
            const textArea = document.createElement("textarea");
            textArea.value = text.trim();
            document.body.appendChild(textArea);
            textArea.select();
            document.execCommand("Copy");
            document.body.removeChild(textArea);
            let tst = document.createElement('div');
            tst.classList = 'toast';
            tst.innerHTML = 'Snippet copied to clipboard!';
            document.body.appendChild(tst);
            setTimeout(function() {
              tst.style.opacity = 0;
              setTimeout(function() {
                document.body.removeChild(tst);
              },300);
            },1700);
          }
        }, false);
      }</script></head><body onload="loader()" class="card-page"><a href="https://github.com/30-seconds/30-seconds-of-code" class="github-corner" aria-label="View source on Github"><svg width="56" height="56" viewBox="0 0 250 250" style="fill:#009688;color:#fff;position:fixed;top:0;border:0;right:0;z-index:1000" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin:130px 106px" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><button class="menu-button"></button><header><h1 class="logo"><a href="./index"><img src="https://30secondsofcode.org/logos/logo_256.png" alt="logo"/><span id="title">&nbsp;30 seconds of code</span> <small>Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.</small></a></h1></header><div class="container card-container"><nav><input class="search" type="search" id="searchInput" onkeyup="search(this)" placeholder="Search..." aria-label="Snippet search"><h4>Adapter</h4><a tags="adapter,function,intermediate" href="./adapter#ary">ary</a> <a tags="adapter,function,intermediate" href="./adapter#call">call</a> <a tags="adapter,function,array,intermediate" href="./adapter#collectinto">collectInto</a> <a tags="adapter,function,intermediate" href="./adapter#flip">flip</a> <a tags="adapter,function,intermediate" href="./adapter#over">over</a> <a tags="adapter,function,intermediate" href="./adapter#overargs">overArgs</a> <a tags="adapter,function,promise,intermediate" href="./adapter#pipeasyncfunctions">pipeAsyncFunctions</a> <a tags="adapter,function,intermediate" href="./adapter#pipefunctions">pipeFunctions</a> <a tags="adapter,function,promise,intermediate" href="./adapter#promisify">promisify</a> <a tags="adapter,function,intermediate" href="./adapter#rearg">rearg</a> <a tags="adapter,intermediate" href="./adapter#spreadover">spreadOver</a> <a tags="adapter,function,intermediate" href="./adapter#unary">unary</a><h4>Array</h4><a tags="array,function,beginner" href="./index#all">all</a> <a tags="array,function,beginner" href="./index#allequal">allEqual</a> <a tags="array,function,beginner" href="./index#any">any</a> <a tags="array,string,utility,intermediate" href="./index#arraytocsv">arrayToCSV</a> <a tags="array,intermediate" href="./index#bifurcate">bifurcate</a> <a tags="array,function,intermediate" href="./index#bifurcateby">bifurcateBy</a> <a tags="array,intermediate" href="./index#chunk">chunk</a> <a tags="array,beginner" href="./index#compact">compact</a> <a tags="array,object,intermediate" href="./index#countby">countBy</a> <a tags="array,intermediate" href="./index#countoccurrences">countOccurrences</a> <a tags="array,recursion,intermediate" href="./index#deepflatten">deepFlatten</a> <a tags="array,math,beginner" href="./index#difference">difference</a> <a tags="array,function,intermediate" href="./index#differenceby">differenceBy</a> <a tags="array,function,intermediate" href="./index#differencewith">differenceWith</a> <a tags="array,beginner" href="./index#drop">drop</a> <a tags="array,beginner" href="./index#dropright">dropRight</a> <a tags="array,function,intermediate" href="./index#droprightwhile">dropRightWhile</a> <a tags="array,function,intermediate" href="./index#dropwhile">dropWhile</a> <a tags="array,beginner" href="./index#everynth">everyNth</a> <a tags="array,beginner" href="./index#filternonunique">filterNonUnique</a> <a tags="array,function,intermediate" href="./index#filternonuniqueby">filterNonUniqueBy</a> <a tags="array,beginner" href="./index#findlast">findLast</a> <a tags="array,function,intermediate" href="./index#findlastindex">findLastIndex</a> <a tags="array,intermediate" href="./index#flatten">flatten</a> <a tags="array,function,intermediate" href="./index#foreachright">forEachRight</a> <a tags="array,object,intermediate" href="./index#groupby">groupBy</a> <a tags="array,beginner" href="./index#head">head</a> <a tags="array,intermediate" href="./index#indexofall">indexOfAll</a> <a tags="array,beginner" href="./index#initial">initial</a> <a tags="array,intermediate" href="./index#initialize2darray">initialize2DArray</a> <a tags="array,math,intermediate" href="./index#initializearraywithrange">initializeArrayWithRange</a> <a tags="array,math,intermediate" href="./index#initializearraywithrangeright">initializeArrayWithRangeRight</a> <a tags="array,math,intermediate" href="./index#initializearraywithvalues">initializeArrayWithValues</a> <a tags="array,recursion,intermediate" href="./index#initializendarray">initializeNDArray</a> <a tags="array,math,intermediate" href="./index#intersection">intersection</a> <a tags="array,function,intermediate" href="./index#intersectionby">intersectionBy</a> <a tags="array,function,intermediate" href="./index#intersectionwith">intersectionWith</a> <a tags="array,intermediate" href="./index#issorted">isSorted</a> <a tags="array,intermediate" href="./index#join">join</a> <a tags="array,string,object,advanced" href="./index#jsontocsv">JSONtoCSV</a> <a tags="array,beginner" href="./index#last">last</a> <a tags="array,string,utility,intermediate" href="./index#longestitem">longestItem</a> <a tags="array,object,advanced" href="./index#mapobject">mapObject</a> <a tags="array,math,beginner" href="./index#maxn">maxN</a> <a tags="array,math,beginner" href="./index#minn">minN</a> <a tags="array,function,beginner" href="./index#none">none</a> <a tags="array,beginner" href="./index#nthelement">nthElement</a> <a tags="array,beginner" href="./index#offset">offset</a> <a tags="array,object,function,intermediate" href="./index#partition">partition</a> <a tags="array,recursion,advanced" href="./index#permutations">permutations</a> <a tags="array,intermediate" href="./index#pull">pull</a> <a tags="array,advanced" href="./index#pullatindex">pullAtIndex</a> <a tags="array,advanced" href="./index#pullatvalue">pullAtValue</a> <a tags="array,function,advanced" href="./index#pullby">pullBy</a> <a tags="array,intermediate" href="./index#reducedfilter">reducedFilter</a> <a tags="array,function,intermediate" href="./index#reducesuccessive">reduceSuccessive</a> <a tags="array,function,intermediate" href="./index#reducewhich">reduceWhich</a> <a tags="array,beginner" href="./index#reject">reject</a> <a tags="array,intermediate" href="./index#remove">remove</a> <a tags="array,random,beginner" href="./index#sample">sample</a> <a tags="array,random,intermediate" href="./index#samplesize">sampleSize</a> <a tags="array,random,intermediate" href="./index#shuffle">shuffle</a> <a tags="array,math,beginner" href="./index#similarity">similarity</a> <a tags="array,math,intermediate" href="./index#sortedindex">sortedIndex</a> <a tags="array,math,function,intermediate" href="./index#sortedindexby">sortedIndexBy</a> <a tags="array,math,intermediate" href="./index#sortedlastindex">sortedLastIndex</a> <a tags="array,math,function,intermediate" href="./index#sortedlastindexby">sortedLastIndexBy</a> <a tags="array,sort,advanced,intermediate" href="./index#stablesort">stableSort</a> <a tags="array,math,intermediate" href="./index#symmetricdifference">symmetricDifference</a> <a tags="array,function,intermediate" href="./index#symmetricdifferenceby">symmetricDifferenceBy</a> <a tags="array,function,intermediate" href="./index#symmetricdifferencewith">symmetricDifferenceWith</a> <a tags="array,beginner" href="./index#tail">tail</a> <a tags="array,beginner" href="./index#take">take</a> <a tags="array,intermediate" href="./index#takeright">takeRight</a> <a tags="array,function,intermediate" href="./index#takerightwhile">takeRightWhile</a> <a tags="array,function,intermediate" href="./index#takewhile">takeWhile</a> <a tags="array,intermediate" href="./index#tohash">toHash</a> <a tags="array,math,beginner" href="./index#union">union</a> <a tags="array,function,intermediate" href="./index#unionby">unionBy</a> <a tags="array,function,intermediate" href="./index#unionwith">unionWith</a> <a tags="array,beginner" href="./index#uniqueelements">uniqueElements</a> <a tags="array,function,intermediate" href="./index#uniqueelementsby">uniqueElementsBy</a> <a tags="array,function,intermediate" href="./index#uniqueelementsbyright">uniqueElementsByRight</a> <a tags="array,math,intermediate" href="./index#uniquesymmetricdifference">uniqueSymmetricDifference</a> <a tags="array,intermediate" href="./index#unzip">unzip</a> <a tags="array,function,advanced" href="./index#unzipwith">unzipWith</a> <a tags="array,beginner" href="./index#without">without</a> <a tags="array,math,intermediate" href="./index#xprod">xProd</a> <a tags="array,intermediate" href="./index#zip">zip</a> <a tags="array,object,intermediate" href="./index#zipobject">zipObject</a> <a tags="array,function,advanced" href="./index#zipwith">zipWith</a><h4>Browser</h4><a tags="browser,array,intermediate" href="./browser#arraytohtmllist">arrayToHtmlList</a> <a tags="browser,intermediate" href="./browser#bottomvisible">bottomVisible</a> <a tags="browser,string,advanced" href="./browser#copytoclipboard">copyToClipboard</a> <a tags="browser,advanced" href="./browser#counter">counter</a> <a tags="browser,utility,beginner" href="./browser#createelement">createElement</a> <a tags="browser,event,advanced" href="./browser#createeventhub">createEventHub</a> <a tags="browser,url,beginner" href="./browser#currenturl">currentURL</a> <a tags="browser,intermediate" href="./browser#detectdevicetype">detectDeviceType</a> <a tags="browser,intermediate" href="./browser#elementcontains">elementContains</a> <a tags="browser,advanced" href="./browser#elementisvisibleinviewport">elementIsVisibleInViewport</a> <a tags="browser,intermediate" href="./browser#getscrollposition">getScrollPosition</a> <a tags="browser,css,beginner" href="./browser#getstyle">getStyle</a> <a tags="browser,css,beginner" href="./browser#hasclass">hasClass</a> <a tags="browser,utility,advanced,promise,advanced" href="./browser#hashbrowser">hashBrowser</a> <a tags="browser,css,beginner" href="./browser#hide">hide</a> <a tags="browser,url,intermediate" href="./browser#httpsredirect">httpsRedirect</a> <a tags="browser,beginner" href="./browser#insertafter">insertAfter</a> <a tags="browser,beginner" href="./browser#insertbefore">insertBefore</a> <a tags="browser,beginner" href="./browser#isbrowsertabfocused">isBrowserTabFocused</a> <a tags="browser,array,beginner" href="./browser#nodelisttoarray">nodeListToArray</a> <a tags="browser,event,advanced" href="./browser#observemutations">observeMutations</a> <a tags="browser,event,intermediate" href="./browser#off">off</a> <a tags="browser,event,intermediate" href="./browser#on">on</a> <a tags="browser,event,advanced" href="./browser#onuserinputchange">onUserInputChange</a> <a tags="browser,utility,intermediate" href="./browser#prefix">prefix</a> <a tags="browser,utility,intermediate" href="./browser#recordanimationframes">recordAnimationFrames</a> <a tags="browser,url,beginner" href="./browser#redirect">redirect</a> <a tags="browser,function,advanced,promise,url" href="./browser#runasync">runAsync</a> <a tags="browser,intermediate" href="./browser#scrolltotop">scrollToTop</a> <a tags="browser,beginner" href="./browser#setstyle">setStyle</a> <a tags="browser,css,beginner" href="./browser#show">show</a> <a tags="browser,css,intermediate" href="./browser#smoothscroll">smoothScroll</a> <a tags="browser,beginner" href="./browser#toggleclass">toggleClass</a> <a tags="browser,event,intermediate" href="./browser#triggerevent">triggerEvent</a> <a tags="browser,utility,random,intermediate" href="./browser#uuidgeneratorbrowser">UUIDGeneratorBrowser</a><h4>Date</h4><a tags="date,math,string,utility,intermediate" href="./date#formatduration">formatDuration</a> <a tags="date,intermediate" href="./date#getcolontimefromdate">getColonTimeFromDate</a> <a tags="date,intermediate" href="./date#getdaysdiffbetweendates">getDaysDiffBetweenDates</a> <a tags="date,beginner" href="./date#getmeridiemsuffixofinteger">getMeridiemSuffixOfInteger</a> <a tags="date,intermediate" href="./date#tomorrow">tomorrow</a><h4>Function</h4><a tags="function,intermediate" href="./function#attempt">attempt</a> <a tags="function,object,intermediate" href="./function#bind">bind</a> <a tags="function,object,intermediate" href="./function#bindkey">bindKey</a> <a tags="function,intermediate" href="./function#chainasync">chainAsync</a> <a tags="function,intermediate" href="./function#compose">compose</a> <a tags="function,intermediate" href="./function#composeright">composeRight</a> <a tags="function,intermediate" href="./function#converge">converge</a> <a tags="function,recursion,intermediate" href="./function#curry">curry</a> <a tags="function,intermediate" href="./function#debounce">debounce</a> <a tags="function,intermediate" href="./function#defer">defer</a> <a tags="function,intermediate" href="./function#delay">delay</a> <a tags="function,utility,beginner" href="./function#functionname">functionName</a> <a tags="function,intermediate" href="./function#hz">hz</a> <a tags="function,advanced" href="./function#memoize">memoize</a> <a tags="function,beginner" href="./function#negate">negate</a> <a tags="function,intermediate" href="./function#once">once</a> <a tags="function,intermediate" href="./function#partial">partial</a> <a tags="function,intermediate" href="./function#partialright">partialRight</a> <a tags="function,promise,intermediate" href="./function#runpromisesinseries">runPromisesInSeries</a> <a tags="function,promise,intermediate" href="./function#sleep">sleep</a> <a tags="function,advanced" href="./function#throttle">throttle</a> <a tags="function,intermediate" href="./function#times">times</a> <a tags="function,intermediate" href="./function#uncurry">uncurry</a> <a tags="function,array,intermediate" href="./function#unfold">unfold</a> <a tags="function,intermediate" href="./function#when">when</a><h4>Math</h4><a tags="math,beginner" href="./math#approximatelyequal">approximatelyEqual</a> <a tags="math,array,beginner" href="./math#average">average</a> <a tags="math,array,function,intermediate" href="./math#averageby">averageBy</a> <a tags="math,intermediate" href="./math#binomialcoefficient">binomialCoefficient</a> <a tags="math,beginner" href="./math#clampnumber">clampNumber</a> <a tags="math,beginner" href="./math#degreestorads">degreesToRads</a> <a tags="math,array,beginner" href="./math#digitize">digitize</a> <a tags="math,beginner" href="./math#distance">distance</a> <a tags="math,array,advanced" href="./math#elo">elo</a> <a tags="math,recursion,beginner" href="./math#factorial">factorial</a> <a tags="math,array,beginner" href="./math#fibonacci">fibonacci</a> <a tags="math,recursion,beginner" href="./math#gcd">gcd</a> <a tags="math,intermediate" href="./math#geometricprogression">geometricProgression</a> <a tags="math,beginner" href="./math#hammingdistance">hammingDistance</a> <a tags="math,beginner" href="./math#inrange">inRange</a> <a tags="math,beginner" href="./math#isdivisible">isDivisible</a> <a tags="math,beginner" href="./math#iseven">isEven</a> <a tags="math,beginner,intermediate" href="./math#isprime">isPrime</a> <a tags="math,recursion,beginner" href="./math#lcm">lcm</a> <a tags="math,utility,advanced" href="./math#luhncheck">luhnCheck</a> <a tags="math,array,function,beginner" href="./math#maxby">maxBy</a> <a tags="math,array,intermediate" href="./math#median">median</a> <a tags="math,array,function,beginner" href="./math#minby">minBy</a> <a tags="math,intermediate" href="./math#percentile">percentile</a> <a tags="math,beginner" href="./math#powerset">powerset</a> <a tags="math,array,intermediate" href="./math#primes">primes</a> <a tags="math,beginner" href="./math#radstodegrees">radsToDegrees</a> <a tags="math,utility,random,intermediate" href="./math#randomintarrayinrange">randomIntArrayInRange</a> <a tags="math,utility,random,beginner" href="./math#randomintegerinrange">randomIntegerInRange</a> <a tags="math,utility,random,beginner" href="./math#randomnumberinrange">randomNumberInRange</a> <a tags="math,intermediate" href="./math#round">round</a> <a tags="math,utility,intermediate" href="./math#sdbm">sdbm</a> <a tags="math,array,intermediate" href="./math#standarddeviation">standardDeviation</a> <a tags="math,array,beginner" href="./math#sum">sum</a> <a tags="math,array,function,intermediate" href="./math#sumby">sumBy</a> <a tags="math,intermediate" href="./math#sumpower">sumPower</a> <a tags="math,beginner" href="./math#tosafeinteger">toSafeInteger</a><h4>Node</h4><a tags="node,string,utility,beginner" href="./node#atob">atob</a> <a tags="node,string,utility,beginner" href="./node#btoa">btoa</a> <a tags="node,utility,string,intermediate" href="./node#colorize">colorize</a> <a tags="node,intermediate" href="./node#hasflags">hasFlags</a> <a tags="node,utility,promise,intermediate" href="./node#hashnode">hashNode</a> <a tags="node,intermediate" href="./node#istravisci">isTravisCI</a> <a tags="node,json,intermediate" href="./node#jsontofile">JSONToFile</a> <a tags="node,array,string,beginner" href="./node#readfilelines">readFileLines</a> <a tags="node,string,beginner" href="./node#untildify">untildify</a> <a tags="node,utility,random,intermediate" href="./node#uuidgeneratornode">UUIDGeneratorNode</a><h4>Object</h4><a tags="object,function,intermediate" href="./object#bindall">bindAll</a> <a tags="object,recursion,intermediate" href="./object#deepclone">deepClone</a> <a tags="object,recursion,intermediate" href="./object#deepfreeze">deepFreeze</a> <a tags="object,intermediate" href="./object#defaults">defaults</a> <a tags="object,recursion,intermediate" href="./object#dig">dig</a> <a tags="object,array,type,advanced" href="./object#equals">equals</a> <a tags="object,function,intermediate" href="./object#findkey">findKey</a> <a tags="object,function,intermediate" href="./object#findlastkey">findLastKey</a> <a tags="object,recursion,intermediate" href="./object#flattenobject">flattenObject</a> <a tags="object,intermediate" href="./object#forown">forOwn</a> <a tags="object,intermediate" href="./object#forownright">forOwnRight</a> <a tags="object,function,intermediate" href="./object#functions">functions</a> <a tags="object,intermediate" href="./object#get">get</a> <a tags="object,function,intermediate" href="./object#invertkeyvalues">invertKeyValues</a> <a tags="object,intermediate" href="./object#lowercasekeys">lowercaseKeys</a> <a tags="object,function,intermediate" href="./object#mapkeys">mapKeys</a> <a tags="object,function,intermediate" href="./object#mapvalues">mapValues</a> <a tags="object,type,intermediate" href="./object#matches">matches</a> <a tags="object,type,function,intermediate" href="./object#matcheswith">matchesWith</a> <a tags="object,array,intermediate" href="./object#merge">merge</a> <a tags="object,intermediate" href="./object#nest">nest</a> <a tags="object,array,beginner" href="./object#objectfrompairs">objectFromPairs</a> <a tags="object,array,beginner" href="./object#objecttopairs">objectToPairs</a> <a tags="object,array,intermediate" href="./object#omit">omit</a> <a tags="object,array,function,intermediate" href="./object#omitby">omitBy</a> <a tags="object,array,intermediate" href="./object#orderby">orderBy</a> <a tags="object,array,intermediate" href="./object#pick">pick</a> <a tags="object,array,function,intermediate" href="./object#pickby">pickBy</a> <a tags="object,intermediate" href="./object#renamekeys">renameKeys</a> <a tags="object,beginner" href="./object#shallowclone">shallowClone</a> <a tags="object,array,string,intermediate" href="./object#size">size</a> <a tags="object,array,intermediate" href="./object#transform">transform</a> <a tags="object,logic,array,intermediate" href="./object#truthcheckcollection">truthCheckCollection</a> <a tags="object,advanced" href="./object#unflattenobject">unflattenObject</a><h4>String</h4><a tags="string,beginner" href="./string#bytesize">byteSize</a> <a tags="string,array,intermediate" href="./string#capitalize">capitalize</a> <a tags="string,regexp,intermediate" href="./string#capitalizeeveryword">capitalizeEveryWord</a> <a tags="string,array,utility,intermediate" href="./string#csvtoarray">CSVToArray</a> <a tags="string,array,object,advanced" href="./string#csvtojson">CSVToJSON</a> <a tags="string,array,intermediate" href="./string#decapitalize">decapitalize</a> <a tags="string,browser,regexp,intermediate" href="./string#escapehtml">escapeHTML</a> <a tags="string,regexp,intermediate" href="./string#escaperegexp">escapeRegExp</a> <a tags="string,intermediate" href="./string#fromcamelcase">fromCamelCase</a> <a tags="string,utility,browser,url,intermediate" href="./string#isabsoluteurl">isAbsoluteURL</a> <a tags="string,regexp,intermediate" href="./string#isanagram">isAnagram</a> <a tags="string,utility,beginner" href="./string#islowercase">isLowerCase</a> <a tags="string,utility,beginner" href="./string#isuppercase">isUpperCase</a> <a tags="string,array,function,utility,beginner" href="./string#mapstring">mapString</a> <a tags="string,utility,regexp,intermediate" href="./string#mask">mask</a> <a tags="string,beginner" href="./string#pad">pad</a> <a tags="string,intermediate" href="./string#palindrome">palindrome</a> <a tags="string,intermediate" href="./string#pluralize">pluralize</a> <a tags="string,regexp,intermediate" href="./string#removenonascii">removeNonASCII</a> <a tags="string,array,beginner" href="./string#reversestring">reverseString</a> <a tags="string,beginner" href="./string#sortcharactersinstring">sortCharactersInString</a> <a tags="string,beginner" href="./string#splitlines">splitLines</a> <a tags="string,recursion,advanced" href="./string#stringpermutations">stringPermutations</a> <a tags="string,utility,regexp,beginner" href="./string#striphtmltags">stripHTMLTags</a> <a tags="string,regexp,intermediate" href="./string#tocamelcase">toCamelCase</a> <a tags="string,regexp,intermediate" href="./string#tokebabcase">toKebabCase</a> <a tags="string,regexp,intermediate" href="./string#tosnakecase">toSnakeCase</a> <a tags="string,beginner" href="./string#truncatestring">truncateString</a> <a tags="string,browser,beginner" href="./string#unescapehtml">unescapeHTML</a> <a tags="string,utility,regexp,advanced" href="./string#urljoin">URLJoin</a> <a tags="string,regexp,intermediate" href="./string#words">words</a><h4>Type</h4><a tags="type,beginner" href="./type#gettype">getType</a> <a tags="type,array,regexp,beginner" href="./type#is">is</a> <a tags="type,array,intermediate" href="./type#isarraylike">isArrayLike</a> <a tags="type,beginner" href="./type#isboolean">isBoolean</a> <a tags="type,array,object,string,beginner" href="./type#isempty">isEmpty</a> <a tags="type,function,beginner" href="./type#isfunction">isFunction</a> <a tags="type,beginner" href="./type#isnil">isNil</a> <a tags="type,beginner" href="./type#isnull">isNull</a> <a tags="type,math,beginner" href="./type#isnumber">isNumber</a> <a tags="type,object,beginner" href="./type#isobject">isObject</a> <a tags="type,object,beginner" href="./type#isobjectlike">isObjectLike</a> <a tags="type,object,intermediate" href="./type#isplainobject">isPlainObject</a> <a tags="type,function,array,string,intermediate" href="./type#isprimitive">isPrimitive</a> <a tags="type,function,promise,intermediate" href="./type#ispromiselike">isPromiseLike</a> <a tags="type,string,beginner" href="./type#isstring">isString</a> <a tags="type,beginner" href="./type#issymbol">isSymbol</a> <a tags="type,beginner" href="./type#isundefined">isUndefined</a> <a tags="type,json,intermediate" href="./type#isvalidjson">isValidJSON</a><h4>Utility</h4><a tags="utility,array,type,beginner" href="./utility#castarray">castArray</a> <a tags="utility,regexp,intermediate" href="./utility#cloneregexp">cloneRegExp</a> <a tags="utility,beginner" href="./utility#coalesce">coalesce</a> <a tags="utility,intermediate" href="./utility#coalescefactory">coalesceFactory</a> <a tags="utility,string,intermediate" href="./utility#extendhex">extendHex</a> <a tags="utility,browser,string,url,intermediate" href="./utility#geturlparameters">getURLParameters</a> <a tags="utility,string,math,advanced" href="./utility#hextorgb">hexToRGB</a> <a tags="utility,url,browser,intermediate" href="./utility#httpget">httpGet</a> <a tags="utility,url,browser,intermediate" href="./utility#httppost">httpPost</a> <a tags="utility,browser,intermediate" href="./utility#isbrowser">isBrowser</a> <a tags="utility,function" href="./utility#mostperformant">mostPerformant</a> <a tags="utility,function,beginner" href="./utility#ntharg">nthArg</a> <a tags="utility,string,intermediate" href="./utility#parsecookie">parseCookie</a> <a tags="utility,string,math,advanced" href="./utility#prettybytes">prettyBytes</a> <a tags="utility,random,beginner" href="./utility#randomhexcolorcode">randomHexColorCode</a> <a tags="utility,intermediate" href="./utility#rgbtohex">RGBToHex</a> <a tags="utility,string,intermediate" href="./utility#serializecookie">serializeCookie</a> <a tags="utility,beginner" href="./utility#timetaken">timeTaken</a> <a tags="utility,intermediate" href="./utility#tocurrency">toCurrency</a> <a tags="utility,math,beginner" href="./utility#todecimalmark">toDecimalMark</a> <a tags="utility,math,intermediate" href="./utility#toordinalsuffix">toOrdinalSuffix</a> <a tags="utility,math,intermediate" href="./utility#validatenumber">validateNumber</a> <a tags="utility,regexp,intermediate" href="./utility#yesno">yesNo</a><h4>Uncategorized</h4><a tags="uncategorized" href="#pipelog">pipeLog</a></nav><main class="col-centered"><span id="top"><br/><br/></span><h2 class="category-name">Uncategorized</h2><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="pipelog">pipeLog</h4><p>Use <code>console.log</code> in a pipeline as this function simply encloses it and returns the passed value. This is especially useful for debugging when you want to log a variable's value before its usage.</p><p>Logs a value and returns it.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">pipeLog</span> <span class="token operator">=</span> data <span class="token operator">=></span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token operator">||</span> data<span class="token punctuation">;</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">pipeLog</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">);</span> <span class="token comment">// logs `1` and returns `1`</span>
</pre></div></main><footer class="col-full-width container"><div class="col-centered"><p style="display:inline-block"><strong>30 seconds of code</strong> is licensed under the <a href="https://github.com/30-seconds/30-seconds-of-code/blob/master/LICENSE">CC0-1.0</a> license.<br>Logos made by <a href="https://github.com/Chalarangelo">Angelos Chalaris</a> and ribbon made by <a href="https://github.com/tholman/github-corners">Tim Holman</a> are licensed under the <a href="https://opensource.org/licenses/MIT">MIT</a> license.<br>Sponsored by <img src="https://30secondsofcode.org/sponsors/DO_Logo_icon_blue.svg" style="vertical-align:sub;padding-right:2px;padding-left:2px" width="20px" height="20px"><a href="https://www.digitalocean.com" alt="DigitalOcean"><span style="color:#0080ff">DigitalOcean</span></a>.</p><br/><p style="display:inline-block"><a href="./about">About</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="./contributing">Contributing</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="./archive">Archive</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="./glossary">Glossary</a></p></div></footer><a class="scroll-to-top" href="#top"></a></div></body></html>